<header role="banner" class="app-header">
  <span class="app-nav-auth">
    <% if the_current_user %>
      <%= link_to the_current_user.name, user_path(the_current_user) %>
      |
      <%= link_to 'Sign out', main_app.destroy_user_session_path,
                  method: :delete %>
    <% else %>
      <%= link_to 'Sign in', main_app.new_user_session_path %>
    <% end %>
  </span>
  <span class="app-nav-logo"><a href="/">Thredded</a> Demo</span>
  <div class="app-nav-theme">
    <span class="app-nav-text">Theme:</span>
    <ul>
      <% themes.each do |theme| %>
        <%= content_tag :li, class: ('app-current' if theme == current_theme), 'data-theme' => theme do -%>
          <% if theme == current_theme -%>
            <span class="app-nav-text"><%= theme.humanize %></span>
          <% else -%>
            <%= button_to main_app.update_theme_path(theme) do %>
              <span class="app-nav-text"><%= theme.humanize %></span>
              <span class="app-nav-icon"><%= inline_svg_tag 'brightness.svg' %></span>
            <% end %>
          <% end -%>
        <% end -%>
      <% end %>
    </ul>
  </div>
  <div class="app-nav-locale">
    <span class="app-nav-locale--selected">
      <span class="app-nav-locale--selected--label">Language: </span>
      <%= I18n.locale.to_s %>
      <span class="app-nav-locale--selected--caret">▽</span>
    </span>
    <div class="app-nav-locale--options">
      <% I18n.available_locales.each do |locale| %>
        <%= content_tag :div, class: ('app-current' if locale.to_s == I18n.locale.to_s),
                        'data-locale' => locale do -%>
          <% if locale.to_s == I18n.locale.to_s -%>
            <span class="app-nav-locale--options--option">
              <%= locale %>
            </span>
          <% else -%>
            <%= button_to locale, main_app.update_locale_path(locale), class: 'app-nav-locale--options--option' %>
          <% end -%>
        <% end -%>
      <% end %>
    </div>
  </div>
</header>
